export function LogMethodCalls(label: string = "", excepts: string[] = []): ClassDecorator {

    return function (constructor: Function) {
        // Get all property names of the class
        const properties = Object.getOwnPropertyNames(constructor.prototype);
        properties.forEach(propertyName => {
            const lowcase = propertyName.toLocaleString();
            for (const except of excepts) {
                if (lowcase.includes(except)) return;
            }

            // 跳过get accesser 因为accessor的访问可能会访问未初始化属性            
            if (typeof Object.getOwnPropertyDescriptor(constructor.prototype, propertyName)?.get === 'function') return;

            const originalMethod = constructor.prototype[propertyName];
            // Check if the property is a function and not the constructor itself
            if (propertyName !== 'constructor' && typeof originalMethod === 'function') {
                // Replace the original method with a new function that includes logging
                constructor.prototype[propertyName] = function (...args: any[]) {
                    const currentTime = new Date().toLocaleTimeString();
                    console.log(`[${currentTime}] [${label}] Calling method: ${propertyName} with arguments:`, args);
                    const result = originalMethod.apply(this, args);
                    console.log(`[${label}] Method: ${propertyName} returned:`, result);
                    return result;
                };
            }
        });
    };

}